package org.pine.web.controller;

import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.pine.api.beans.request.PageRequest;
import org.pine.api.beans.request.UserQueryRequest;
import org.pine.api.beans.response.PageResponse;
import org.pine.api.beans.response.UserQueryResponse;
import org.pine.common.beans.Result;
import org.pine.service.UserService;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 用户控制器
 *
 * @author pine
 * @version v1.0
 * @since 2025-04-12 16:57
 */
@Slf4j
@Tag(name = "用户控制器")
@RestController
@RequestMapping("/user")
public class UserController {

    @Resource
    private UserService userService;

    @Operation(summary = "分页查询用户")
    @PostMapping("/listByPage")
    public Result<PageResponse<UserQueryResponse>> listByPage(@RequestBody PageRequest<UserQueryRequest> request) {
        request.setDefaultParam();
        log.info("请求参数={}", request);

        return Result.success(userService.listByPage(request));
    }
}
